package com.example.practical_training_projects.mapper;
import com.example.practical_training_projects.entity.test;
import com.example.practical_training_projects.vo.votestclass;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface testMapper {
    @Select("select * from test")
    List<test> getAlltest();

    @Delete("delete from test where t_uid=#{t_uid}")
    Integer deleteTest(Integer t_uid);
    @Insert("insert into test (t_context,t_answer1,t_answer2,ts_uid)"+
            " values (#{t_context},#{t_answer1},#{t_answer2},#{ts_uid})")
    Integer insertTest(test t_uid);

    @Select("select * from test where t_uid = #{t_uid}")
    test findTestuid(Integer t_uid);

    @Update("update test set t_context=#{t_context},t_answer1=#{t_answer1},t_answer2=#{t_answer2},ts_uid=#{ts_uid} where t_uid = #{t_uid}")
    Integer updateTest(test test1);

    @Select("select *from test where t_context like '%${name}%'")
    List<test>  getContest(String t_context);

    @Select("select *from test where t_class like '%${name}%'")
    List<test>  getClass(String t_class);

    @Select("select t.*,ts.ts_class from test t join testselect ts on t.ts_uid = ts.ts_uid  order by t_uid desc\n")
    List<votestclass> findAlltestAndclass();

    @Select("select t.*,ts.ts_class from test t join testselect ts on t.ts_uid = ts.ts_uid where t.t_context like '%${name}%' ")
    List<votestclass> findtestBycontext(String t_context);
    @Select("select t.*,ts.ts_class from test t join testselect ts on t.ts_uid = ts.ts_uid where t.t_context like '%${t_context}%'\n" +
            " and ts.ts_uid like '%${ts_uid}%'")
    List<votestclass> findtestBycontextAndclassuid(@Param("ts_uid") Integer ts_uid,@Param("t_context") String t_context);



}
